﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cal_control_table
{

    public class firstclass
    {

        public static void fun(double num1, double num2, string symbol)
        {
            double count;

            switch (symbol)
            {
                case "+":
                    count = num1 + num2;
                    Console.WriteLine("您要计算的两数之和为:{0}", count);
                    break;
                case "-":
                    count = num1 - num2;
                    Console.WriteLine("您要计算的值为:{0}", count);
                    break;
                case "×":
                    count = num1 * num2;
                    Console.WriteLine("您要计算的值为:{0}", count);
                    break;
                case "÷":
                    if (num2 != 0)
                    {
                        count = num1 / num2;
                        Console.WriteLine("您要计算的值为:{0}", count);
                        break;
                    }
                    else
                    {
                        Console.WriteLine("输入有误!请退出重新输入!!!");
                    }
                    break;
                default:
                    Console.WriteLine("运算符不存在");
                    break;
            }
        }
    }

    class Program
    {

        static void Main(string[] args)
        {
            Console.WriteLine("请输入要计算的第一个值:");
            double a = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入要计算的第二个值:");
            double b = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入运算符:+ - × ÷");
            string fh = Console.ReadLine();
            firstclass.fun(a, b, fh);//对方法的调用
            Console.ReadLine();

        }
    }
}
